﻿using System.Collections.Generic;
using Lucy.Editor.Framework;

namespace Lucy.Editor.ViewModels
{
    class FolderTreeViewItemViewModel : TreeViewItemViewModel
    {
        public ViewModelCommand CreateSubFolderCommand { get; private set; }
        public ViewModelCommand DeleteFolderCommand { get; private set; }

        public FolderTreeViewItemViewModel()
        {
            Icon = "Images/folder.png";
            CreateSubFolderCommand = new ViewModelCommand(CreateSubFolderExecute) { Name = "Create Subfolder" };
            DeleteFolderCommand = new ViewModelCommand(DeleteFolderExecute) { Name = "Delete Folder"};
        }

        private void CreateSubFolderExecute()
        {
            CreateChild(new FolderTreeViewItemViewModel() {Name = "Folder1"});
            IsExpanded = true;
        }

        private void DeleteFolderExecute()
        {
            Parent.RemoveChild(this);
        }

        public override IEnumerable<ViewModelCommand> ContextMenuCommands
        {
            get
            {
                yield return CreateSubFolderCommand;
                yield return DeleteFolderCommand;
            }
        }
    }
}
